<template>
    <div class="container">
        <p>点击次数number：{{count}}</p>
        <p>现在是{{oddOrEven}}</p>
        <button @click="handleAdd">加</button>
        <button @click="handleJian">减</button>
        <button @click="handleAddOdd">只有是奇数的时候才增加</button>
        <button @click="handleAddAsync">异步增加点击增加</button>
    </div>
</template>

<script>
    export default {
        name: "App",
        data () {
            return {
                count:0
            }
        },
        computed:{
            oddOrEven () {
                return this.count%2==0?'偶数':'奇数';
            }
        },
        methods:{
            handleAdd () {
                this.count++;
            },
            handleJian () {
                this.count--;
            },
            handleAddOdd () {
                if(this.count%2!=0){
                    this.count++;
                }
            },
            handleAddAsync () {
                setTimeout(() => {
                    this.count++
                },1000)
            }
        }

    }
</script>

<style lang="stylus" scoped>
</style>